"""
作者：Leagolas
日期：2023年12月20日
"""

import numpy as np

# 截尾
def truncate(df):
    for column in list(df.columns):
        mean = df[column].mean()
        std = df[column].std()
        upper_bound = mean + 3 * std
        lower_bound = mean - 3 * std
        df[column] = np.clip(df[column], lower_bound, upper_bound, axis=0)
    return df



# zscore标准化
def standardize(df):
    for col in list(df.columns):
        mean = np.mean(df[col])
        std = np.std(df[col])
        df[col] = (df[col] - mean) / std
    return df


def normalize(df):
    for col in list(df.columns):
        min = np.min(df[col])
        max = np.max(df[col])
        df[col] = (df[col] - min) / (max - min)
    return df